package com.newland.mesdk.demo.interfaceimpl;

import java.util.concurrent.TimeUnit;

import com.newland.mtype.ModuleType;
import com.newland.mtype.event.DeviceEventListener;
import com.newland.mtype.module.common.pin.AccountInputType;
import com.newland.mtype.module.common.pin.K21Pininput;
import com.newland.mtype.module.common.pin.K21PininutEvent;
import com.newland.mtype.module.common.pin.KeyManageType;
import com.newland.mtype.module.common.pin.KeySoundParams;
import com.newland.mtype.module.common.pin.LoadPKResultCode;
import com.newland.mtype.module.common.pin.LoadPKType;
import com.newland.mtype.module.common.pin.PeripheralMonitor;
import com.newland.mtype.module.common.pin.PinConfirmType;
import com.newland.mtype.module.common.pin.PinInputResult;
import com.newland.mtype.module.common.pin.WorkingKey;
import com.newland.mesdk.demo.util.ModuleBase;

/**
 * Created by YJF . K21连接方式下的密码输入接口实现类
 */
public class K21PininputInterfaceImpl extends ModuleBase {
	private K21Pininput pinInput;

	public K21PininputInterfaceImpl() {
		pinInput = (K21Pininput) factory.getModule(ModuleType.COMMON_PININPUT);
	}

	//
	public LoadPKResultCode laodK21Pk(LoadPKType keytype, int pkIndex, String pkLength, byte[] pkModule, byte[] pkExponent, byte[] index, byte[] mac) {
		LoadPKResultCode loadpkresult = pinInput.loadPublicKey(keytype, pkIndex, pkLength, pkModule, pkExponent, index, mac);
		return loadpkresult;
	}

	//开启一个按鍵音可控的密码输入过程
	public void startK21StandPininput(String displayContent, WorkingKey workingKey, KeyManageType pinManageType, AccountInputType acctInputType,
			String acctSymbol, int inputMaxLen, byte[] pwdLengthRange, byte[] pinPadding, PinConfirmType pinConfirmType, long timeout,
			TimeUnit timeunit, KeySoundParams keySoundParams, PeripheralMonitor[] peripheralMonitor,
			DeviceEventListener<K21PininutEvent> inputListener) {
		pinInput.startStandardPinInput(displayContent, workingKey, pinManageType, acctInputType, acctSymbol, inputMaxLen, pwdLengthRange, pinPadding,
				pinConfirmType, timeout, timeunit, keySoundParams, peripheralMonitor, inputListener);
	}

	public PinInputResult encryptPIN(WorkingKey wk, KeyManageType pinManageType, AccountInputType acctInputType, String acctSymbol, byte[] pin) {
		return pinInput.encryptPIN(wk, pinManageType, acctInputType, acctSymbol, pin);
	}
}
